

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/avatar.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Yaocan Chen">
  <meta name="keywords" content="">
  
    <meta name="description" content="写一个可以用键盘上下左右控制的 带菜单选择的脚本">
<meta property="og:type" content="article">
<meta property="og:title" content="写一个可以键盘控制的shell脚本">
<meta property="og:url" content="https://yaocc.cc/menushell/index.html">
<meta property="og:site_name" content="cc">
<meta property="og:description" content="写一个可以用键盘上下左右控制的 带菜单选择的脚本">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://yaocc.cc/img/menu/menu.gif">
<meta property="article:published_time" content="2021-10-19T10:47:54.000Z">
<meta property="article:modified_time" content="2025-01-21T12:09:53.113Z">
<meta property="article:author" content="Yaocan Chen">
<meta property="article:tag" content="LINUX">
<meta property="article:tag" content="SHELL">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://yaocc.cc/img/menu/menu.gif">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>写一个可以键盘控制的shell脚本 - cc</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"yaocc.cc","root":"/","version":"1.9.2","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 30vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>CC</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/banner.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="写一个可以键盘控制的shell脚本"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2021-10-19 18:47" pubdate>
          2021年10月19日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          <!-- compatible with older versions-->
          4.1k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          <!-- compatible with older versions-->
          35 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">写一个可以键盘控制的shell脚本</h1>
            
            
              <div class="markdown-body">
                
                <!-- markdown-toc GitLab -->

<ul>
<li><a href="#%E5%86%99%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E9%94%AE%E7%9B%98%E6%8E%A7%E5%88%B6%E7%9A%84shell%E8%84%9A%E6%9C%AC">写一个可以键盘控制的shell脚本</a><ul>
<li><a href="#menu%E8%84%9A%E6%9C%AC">MENU脚本</a><ul>
<li><a href="#menu%E8%84%9A%E6%9C%AC%E8%AE%B2%E8%A7%A3">MENU脚本讲解</a></li>
</ul>
</li>
<li><a href="#get_char%E8%AF%A6%E8%A7%A3">_get_char详解</a></li>
<li><a href="#demo%E8%84%9A%E6%9C%AC">DEMO脚本</a></li>
<li><a href="#%E6%95%88%E6%9E%9C%E5%B1%95%E7%A4%BA">效果展示</a></li>
<li><a href="#%E4%B8%80%E4%BA%9B%E7%A4%BA%E8%8C%83%E8%84%9A%E6%9C%AC">一些示范脚本</a></li>
</ul>
</li>
</ul>
<!-- markdown-toc -->

<h2 id="写一个可以键盘控制的shell脚本"><a href="#写一个可以键盘控制的shell脚本" class="headerlink" title="写一个可以键盘控制的shell脚本"></a>写一个可以键盘控制的shell脚本</h2><p><a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV11r4y1g73U/">bilibili视频链接</a><br><img src="/img/menu/menu.gif" srcset="/img/loading.gif" lazyload alt="show"></p>
<h3 id="MENU脚本"><a href="#MENU脚本" class="headerlink" title="MENU脚本"></a>MENU脚本</h3><p><a href="/file/menu">menu脚本文件 可以直接保存到本地</a></p>
<p>若无法下载 则手动编辑本文文件</p>
<p>!!!PS!!!<br>menu()中的 ^C ^M ^[ 分别代表ctrl+c 回车 esc 且不能直接用字符形式输入<br>输入方法为<br>在vim或vi插入模式中(ctrl+v会触发源字符输入模式)<br>^C: ctrl-v ctrl-c<br>^M: ctrl-v enter<br>^[: ctrl-v esc</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_"># </span><span class="language-bash">menu</span><br>_green() &#123; printf &quot;\033[32m$*\033[0m&quot;; &#125;<br>_get_char() &#123; SAVEDSTTY=`stty -g`; stty -echo; stty raw; dd if=/dev/tty bs=1 count=1 2&gt; /dev/null; stty -raw; stty echo; stty $SAVEDSTTY; &#125;<br>_list() &#123;<br>    # 渲染tabs行<br>    text=&#x27;&#x27;<br>    for ((i = 0; i &lt; $&#123;#menu_tabs[@]&#125;; i++)); do<br>        _tab=$&#123;menu_tabs[$i]&#125;<br>        [ &quot;$_tab&quot; = &quot;$&#123;menu_tabs[$tab_index]&#125;&quot; ] &amp;&amp; text=&quot;$text $(_green $_tab)&quot; || text=&quot;$text $_tab&quot;<br>    done<br><br>    [ &quot;$text&quot; ] &amp;&amp; echo -e &quot;   $text\n&quot;<br><br>    # 渲染菜单选项行<br>    for ((i = 0; i &lt; $&#123;#menu_items[@]&#125;; i++)); do<br>        _item=$&#123;menu_items[$i]&#125;<br>        test &quot;$&#123;_item&#125;&quot; = &quot;$&#123;menu_items[$item_index]&#125;&quot; &amp;&amp; echo -e $(_green &quot; -&gt; $&#123;_item[@]&#125;&quot;) || echo &quot;    $&#123;_item[@]&#125;&quot;<br>    done<br>&#125;<br>_key() &#123;<br>    # 计算新的tab_index和tab<br>    tab_index=$(($tab_index+$1))<br>    len=$&#123;#menu_tabs[*]&#125;<br>    test $tab_index -lt 0 &amp;&amp; tab_index=$((len - 1))<br>    test $tab_index -gt $((len - 1)) &amp;&amp; tab_index=0<br>    tab=$&#123;menu_tabs[$tab_index]&#125;<br><br>    # 计算新的item_index和item<br>    item_index=$(($item_index+$2))<br>    len=$&#123;#menu_items[*]&#125;<br>    test $item_index -lt 0 &amp;&amp; item_index=$((len - 1))<br>    test $item_index -gt $((len - 1)) &amp;&amp; item_index=0<br>    item=$&#123;menu_items[$item_index]&#125;<br><br>    clear<br><br>    pre_hook<br>    _list<br>    after_hook<br><br>    # 有时会存在pre_hook或after_hook操作了tab或item的情况 需要做一层保护<br>    tab=$&#123;menu_tabs[$tab_index]&#125;<br>    item=$&#123;menu_items[$item_index]&#125;<br>&#125;<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_">#</span><span class="language-bash"><span class="hljs-comment">##############################################</span></span><br><br>function pre_hook() &#123; :; &#125;<br>function after_hook() &#123; :; &#125;<br>menu_tabs=()<br>menu_items=()<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_"># </span><span class="language-bash">调用menu方法展开菜单</span><br><span class="hljs-meta prompt_"># </span><span class="language-bash">上下左右移动tab或item，回车选中 q Q ctrl-c 退出脚本</span><br>menu() &#123;<br>    _key 0 0<br>    while :; do<br>        key=`_get_char`<br>        case &quot;$key&quot; in<br>            &#x27;q&#x27;|&#x27;Q&#x27;|&#x27;^C&#x27;) exit 1 ;;<br>            &#x27;^M&#x27;) break ;;<br>            &#x27;^[&#x27;)<br>                secondchar=`_get_char`<br>                thirdchar=`_get_char`<br>                case &quot;$thirdchar&quot; in<br>                    A) _key 0 -1 ;;<br>                    B) _key 0 1 ;;<br>                    D) _key -1 0 ;;<br>                    C) _key 1 0 ;;<br>                esac ;;<br>        esac<br>    done<br>&#125;<br></code></pre></td></tr></table></figure>

<h4 id="MENU脚本讲解"><a href="#MENU脚本讲解" class="headerlink" title="MENU脚本讲解"></a>MENU脚本讲解</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs plaintext"># 用到的依赖func，这些不允许用户自定义或主动调用<br>_green(): 用于打印绿色文本<br>_get_char(): 用于从键盘获取操作<br>_list(): 渲染菜单<br>_key(): 计算新的tab_index、item_index并渲染菜单的func<br><br># 用户可自定义的变量和func<br>menu_tabs: 用于自定义tab项 列表 例如 (1 2 3 4)<br>menu_items: 用于自定义当前的item项 列表 例如 (&#x27;item1&#x27; &#x27;item2&#x27; &#x27;item3&#x27;)<br>pre_hook(): 发生在渲染菜单前的钩子方法(此时新的tab_index、item_index已计算完成)<br>after_hook(): 发生在渲染菜单后的钩子方法<br><br># 用户可使用的变量和func<br>tab_index: 当前的tab索引号 从0开始<br>item_index: 当前的item索引号 从0开始<br>tab: 当前的tab<br>item: 当前的item<br>menu(): 进入菜单选择状态的入口func<br></code></pre></td></tr></table></figure>

<h3 id="get-char详解"><a href="#get-char详解" class="headerlink" title="_get_char详解"></a>_get_char详解</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs shell">_get_char() &#123;<br>  SAVEDSTTY=`stty -g`; # 保存tty设置<br>  stty -echo;          # tty 关闭回显<br>  stty raw;            # tty 开启raw模式<br>  dd if=/dev/tty bs=1 count=1 2&gt; /dev/null; # 读取一个输入<br>  stty -raw;           # tty 关闭raw模式<br>  stty echo;           # tty 开始回显<br>  stty $SAVEDSTTY;     # 还原tty设置<br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="DEMO脚本"><a href="#DEMO脚本" class="headerlink" title="DEMO脚本"></a>DEMO脚本</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs shell">source ./menu<br>menu_tabs=(&#x27;tab1&#x27; &#x27;tab2&#x27; &#x27;tab3&#x27;)<br>menu_items=(&#x27;item1&#x27; &#x27;item2&#x27; &#x27;item3&#x27;)<br>pre_hook() &#123;<br>    echo &#x27;请选择tab or item:&#x27;<br>&#125;<br>after_hook() &#123;<br>    echo &#x27;当前选中项为:&#x27; $&#123;menu_tabs[$tab_index]&#125; $&#123;menu_items[$item_index]&#125;<br>&#125;<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_"># </span><span class="language-bash">调用 func: menu 开始菜单 [上下左右移动] [回车选中] [q或esc或ctrl c结束]</span><br>menu<br>echo 结束了<br>echo 最终选中的项为: $&#123;menu_tabs[$tab_index]&#125; $&#123;menu_items[$item_index]&#125;<br></code></pre></td></tr></table></figure>

<h3 id="效果展示"><a href="#效果展示" class="headerlink" title="效果展示"></a>效果展示</h3><p><img src="/img/%E5%A6%82%E4%BD%95%E5%86%99%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E9%94%AE%E7%9B%98%E6%8E%A7%E5%88%B6%E7%9A%84shell%E8%84%9A%E6%9C%AC/001.gif" srcset="/img/loading.gif" lazyload alt="show"></p>
<h3 id="一些示范脚本"><a href="#一些示范脚本" class="headerlink" title="一些示范脚本"></a>一些示范脚本</h3><p>快速连接远程服务器  </p>
<p>.&#x2F;ssh.sh 开始菜单选择对应命令执行<br>.&#x2F;ssh.sh *非空 直接执行 ssh *</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_">#</span><span class="language-bash">!/bin/bash</span><br><br>source ./menu<br><br>menu_items=(&quot;跳板机&quot; &quot;腾讯云&quot; &quot;跳板机2&quot; &quot;跳板机win&quot; &quot;翻墙机&quot; &quot;公网机&quot;)<br><br>cmds[0]=&#x27;ssh **@a.b.com&#x27;<br>cmds[1]=&#x27;ssh root@host1&#x27;<br>cmds[2]=&#x27;sshpass -p ****** ssh **@jms.hwwt2.com -p 2223&#x27;<br>cmds[3]=&#x27;rdesktop -u ******** -p ****** ip:3390 -r sound:off -g 1920x1080&#x27;<br>cmds[4]=&#x27;ssh root@host2&#x27;<br>cmds[5]=&#x27;ssh root@255.255.255.251&#x27;<br><br>after_hook() &#123;<br>    echo<br>    echo &#x27;   &#x27;$&#123;cmds[$item_index]&#125;<br>&#125;<br><br>case $1 in<br>    &#x27;&#x27;)<br>        menu<br>        echo 连接$&#123;menu_items[$item_index]&#125;<br>        exec $&#123;cmds[$item_index]&#125;<br>        ;;<br>    *) ssh $*;;<br>esac<br></code></pre></td></tr></table></figure>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/LINUX/">#LINUX</a>
      
        <a href="/tags/SHELL/">#SHELL</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-4">
    <div style="float:right">
      <img src="https://github.com/yaocccc/yaocccc/raw/master/qr.png" srcset="/img/loading.gif" lazyload style="height: 110px !important;width: 110px !important;">
    </div>
    <div class="license-title">
      <div>写一个可以键盘控制的shell脚本</div>
      <div>https://yaocc.cc/menushell/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Yaocan Chen</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2021年10月19日</div>
        </div>
      
      
      <div class="license-meta-item">
        <div>许可协议</div>
        <div>
          
            
            
              <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
              <span class="hint--top hint--rounded" aria-label="BY - 署名">
                <i class="iconfont icon-by"></i>
              </span>
              </a>
            
          
        </div>
      </div>
    </div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/vimmacro/" title="vim宏操作">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">vim宏操作</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/golangforrangetrap/" title="golang中for range的坑点">
                        <span class="hidden-mobile">golang中for range的坑点</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  <article id="comments" lazyload>
    
  <script type="text/javascript">
    Fluid.utils.loadComments('#comments', function() {
      var light = 'github-light';
      var dark = 'github-dark';
      var schema = document.documentElement.getAttribute('data-user-color-scheme');
      if (schema === 'dark') {
        schema = dark;
      } else {
        schema = light;
      }
      window.UtterancesThemeLight = light;
      window.UtterancesThemeDark = dark;
      var s = document.createElement('script');
      s.setAttribute('src', 'https://utteranc.es/client.js');
      s.setAttribute('repo', 'yaocccc/utterances');
      s.setAttribute('issue-term', 'pathname');
      
      s.setAttribute('label', 'utterances');
      
      s.setAttribute('theme', schema);
      s.setAttribute('crossorigin', 'anonymous');
      document.getElementById('comments').appendChild(s);
    })
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


  </article>


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://github.com" target="_blank" rel="nofollow noopener"><span>Github</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/yaocccc" target="_blank" rel="nofollow noopener"><span>yaocccc</span></a> <div style="font-size: 0.85rem; margin-top:10px"> <span id="timeDate">载入天数...</span> <span id="times">载入时分秒...</span> <script src="/js/duration.js"></script> </div> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://cdn.jsdelivr.net/npm/tocbot@4.12.2/dist/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      headingSelector : CONFIG.toc.headingSelector || 'h1,h2,h3,h4,h5,h6',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      collapseDepth   : CONFIG.toc.collapseDepth || 0,
      scrollSmooth    : true,
      headingsOffset  : -boardTop
    });
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }
  });
</script>


  <script src=https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://cdn.jsdelivr.net/npm/anchor-js@4.3.0/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));
  });
</script>


  
<script>
  Fluid.utils.createScript('https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
